home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 19
/
Aminet 19 (1997)(GTI - Schatztruhe)[!][Jun 1997].iso
/
Aminet
/
gfx
/
board
/
rtgmasdriv.lha
/
driver
/
example2.s
< prev
next >
Wrap
Text File
|
1997-03-28
|
9KB
|
274 lines
***************************************************
* The ASM Version of the Example of the Generic *
* rtgmaster game videodriver. The Generic *
* rtgmaster videodriver is a linkable object file *
* that works together with any C or ASM code and *
* should work okay as video driver for most *
* games. It already opens all needed libraries *
* and all that stuff. It is coded in C, but *
* internally calls a lot of ASM functions. It is *
* in fact used by some of the games mentioned *
* in the rtgmaster docs. This example is a simple *
* example about how to use this driver. *
* The driver does not give you all features of *
* rtgmaster, but it is more easy to use for *
* people who never used libraries before. *
* You have to install the rtgmaster includes *
* to use it. *
***************************************************
Include "vid_rtgm.i"
XDEF _StartIt
_StartIt
***************************************************
* We want to copy a 320x200 rectangle, later. *
***************************************************
lea myrect,a0
move.l #64,vr_x(a0)
move.l #64,vr_y(a0)
move.l #128,vr_width(a0)
move.l #100,vr_height(a0)
***************************************************
* Init the modes. We want only LUT8 modes (8 Bit *
* modes. If we would like for example LUT8 or *
* RGB16 or RGB15 modes, we would provide *
* LUT8+RGB16+RGB15 as parameter. Look at *
* vid_rtgm.i for the possible constants. These *
* constants show you all colortypes available *
* on Amiga GFX Boards. Only 8 Bit is the same *
* on all boards. We want to use an invisible *
* pointer. We don't want to use an extra vram *
* buffer to be allocated (if we would want that, *
* the extra buffer would be available with the *
* variable extravram. *
**************************************************/
***************************************************
* types : *
* MOVE16 = use Move16 for 8 Bit, rtgmaster *
* CopyRtgPixelArray for 15/16/24 Bit. *
* RTGMASTER = use rtgmaster CopyRtgPixelArray for *
* all depths. (Move16 does not run on all hard- *
* ware, so be sure to allow this option. rtgmaster*
* function is not much slower than the other *
* possible functions. *
* BLITTER = Use the GFX Board Blitter to fake *
* Doublebuffering. This is quite slow. *
* DOUBLEBUFFER = Use Doublebuffering. This does *
* flicker on some machines. *
***************************************************
***************************************************
* Speed : *
* RTGMASTER = 1.0 (higher value = faster) *
* COPY_MOVE_MOVE without Src/Destination Offset *
* = 1.002 *
* COPY_MOVEM_MOVEM = 1.215 *
* FCOPY = 1.227 *
* Source of this driver is provided, so if you *
* want to change the copy function to be used, *
* simply modify the vid_rtgm.c and fcopy.s *
* files. *
***************************************************
***************************************************
* 0 is no extra vram buffer, 1 is use extra vram *
* buffer. This buffer is free to do everything *
* with it you want to do with it. *
***************************************************
***************************************************
* Move16 and Rtgmaster use a Fastcopy Buffer for *
* buffer, the other two methods use a slower *
* Videoram Buffer. *
***************************************************
move.l #LUT8,d0
move.l #MOVEM,d1
move.l #NOPOINTER,d2
move.l #0,d3
***************************************************
* This example does not use the Screenmode- *
* Requester. If you want an example using the *
* Screenmode-Requester, have a look at the C *
* example (you have to provide a MyMode structure *
* in a0 then). *
***************************************************
move.l #0,a0
jsr _RTGM_Init
***************************************************
* Init the example Palette. *
***************************************************
lea palette,a0
move.l #768,d1
palloop:
move.b #0,(a0)+
dbra d1,palloop
lea palette,a0
move.b #255,3(a0)
cmp.l #0,d0
beq Quit
***************************************************
* In this example we simply use the first *
* available screenmode :) *
* An actual game should better use a Screenmode *
* of a certain size, for example 320x200. *
***************************************************
move.l d0,a0
move.l a0,modes
lea lvid,a1
move.l vm_width(a0),d0
move.l d0,vd_width(a1)
move.l vm_height(a0),d0
move.l d0,vd_height(a1)
move.l vm_rowbytes(a0),d0
move.l d0,vd_rowbytes(a1)
***************************************************
* Set the Mode, open the Screen, set the Palette. *
***************************************************
move.l a1,a0
move.l modes,a1
move.l vm_setmode(a1),a2
jsr (a2)
lea lvid,a0
move.l modes,a1
lea palette,a2
move.l vm_setpalette(a1),a3
jsr (a3)
jsr _RTGM_SetPalette
***************************************************
* The Mainloop of this example consists of a *
* Buffer-Swapping (MOVE16 and RTGMASTER use *
* CPU-Copy, BLITTER uses Blitter-Copy, *
* DOUBLEBUFFER uses Doublebuffering (which does *
* not run flickerfree on some GFX Boards, support *
* at least RTGMASTER !!!) To render the offscreen *
* Buffer, render to lvid.buffer !!! *
* If you provide the parameter VID_WAIT_NONE, no *
* synching will be done. Synching is only needed *
* for DOUBLEBUFFERING, MOVE16, RTGMASTER and *
* BLITTER do not need it. *
* For trying the thing out, i am initializing the *
* backbuffer to some values. *
***************************************************
move.l #16000,d0
sub.l #1,d0
lea lvid,a0
move.l vd_buffer(a0),a0
theloop:
move.l #$01010101,(a0)+
dbra d0,theloop
***************************************************
* For "Loading..." symbols and something like that*
* this driver has the calls begindirectrect and *
* enddirectrect. They store the Background. *
* They use simple longwordcopy, so they are not *
* fast. They can't handle anything bigger than *
* 24x24. They work in 8/15/16/24 Bit. *
***************************************************
lea lvid,a0
move.l modes,a1
move.l #160,d0
move.l #100,d1
lea symbol,a2
move.l #3,d2
move.l #3,d3
move.l vm_begindirectrect(a1),a3
jsr (a3)
***************************************************
* Wait for the user to press the left mousebutton *
* to remove the thing again. *
***************************************************
waitloop:
btst #6,$bfe001
bne waitloop
lea lvid,a0
move.l modes,a1
move.l #160,d0
move.l #100,d1
move.l #3,d2
move.l #3,d3
move.l vm_enddirectrect(a1),a2
jsr (a2)
mainloop:
lea lvid,a0
move.l modes,a1
lea myrect,a2
move.l #VID_WAIT_VSYNC,d0
move.l vm_swapbuffers(a1),a3
jsr (a3)
***************************************************
* Sys_SendKeyEvent only reacts on Keypresses. If *
* you also want Mouseevents, you have to modify *
* the vid_rtgm.c or use rtgmaster functions to do *
* so. Sys_SendKeyEvent returns RawKey codes or 0. *
* It includes the KeyUp/KeyDown information. *
***************************************************
move.l modes,a1
move.l vm_sendkeyevents(a1),a2
jsr (a2)
***************************************************
* This function returns keypress information in *
* me_rawkey, qualifiers (like Shift) in *
* me_qualifier, mouse info (like MENUUP) in *
* me_mouse, and it ALWAYS returns the current *
* mouseposition in me_x and me_y. *
* We quit on CTRL q in this example. *
***************************************************
move.l d0,a0
move.w me_rawkey(a0),d0
move.w me_qualifier(a0),d1
cmp.w #16,d0
bne .nope
and.w #CONTROL,d1
cmp.w #0,d1
beq .nope
bra .pressed
.nope:
bra mainloop
***************************************************
* Before quitting, free all allocated resources. *
***************************************************
.pressed:
lea lvid,a0
move.l modes,a1
move.l vm_closemode(a1),a2
jsr (a2)
Quit:
rts
modes: dc.l 0
lvid: dc.l 0,0,0,0,0,0,0
myrect: dc.l 0,0,0,0,0
palette: ds.b 769,0
symbol: dc.b 1,1,1,1,1,1,1,1,1
END